package com.techsoul.module.tms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.techsoul.common.core.pojo.Result;
import com.techsoul.module.tms.pojo.param.TPoPurchaseOrderItemSaveParam;
import com.techsoul.module.tms.pojo.param.TPoPurchaseOrderItemSearchParam;
import com.techsoul.module.tms.service.ITPoPurchaseOrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 采购订单明细表 前端控制器
 * </p>
 *
 * @author liuen
 * @since 2019-09-10
 */
@RestController
@RequestMapping("/tms/purchaseOrderItem")
public class TPoPurchaseOrderItemController {

    @Autowired
    private Result result;

    @Autowired
    private ITPoPurchaseOrderItemService service;

    @PostMapping
    public Result insert(@RequestBody TPoPurchaseOrderItemSaveParam params){
        return result.success(service.insert(params));
    }

    @DeleteMapping(value = "/{id}")
    public Result delete(@PathVariable String id){
        service.delete(id);
        return result.success();
    }

    @PutMapping(value = "/{id}")
    public Result update(@PathVariable String id, @RequestBody TPoPurchaseOrderItemSaveParam params){
        service.update(id, params);
        return result.success();
    }

    @GetMapping(value = "/{id}")
    public Result findById(@PathVariable("id") String id){
        return result.success(service.findById(id));
    }

    @PostMapping(value = "/search")
    public Result findAll(@RequestBody TPoPurchaseOrderItemSearchParam params){
        return result.success(service.findAll(params));
    }

    @PostMapping(value = "/search/{currentPage}/{pageSize}")
    public Result findAll(@RequestBody TPoPurchaseOrderItemSearchParam params, @PathVariable Integer currentPage, @PathVariable Integer pageSize){
        return result.success(this.service.findAll(params, currentPage, pageSize));
    }

}
